<?php
/*****************************************
 This file is part of the Dynamo Core CMS
 Copyright (c) Dynamo Studios 2008

 *** NOTE ***
 Permission is hereby granted to execute this file as a
 web service under the terms of the license agreement.

 See LICENSE.txt, in the system folder.

 All other rights, other than those expressed in the license
 document, are reserved.

 ****************************************/

/**
 * @name Client Layer Interface
 * @version 0.3.3 (Alvin)
 * @abstract
 * Provides interfaces for displaying and rendering
 * data to the client.
 *
 * @author Sean Micklethwaite
 */


interface IDycmsDisplayable
/**
* @desc
* Defines all objects which return data to the client
*/
{
	function Display();
	function GetLabel();
}

class cDycmsClientNode implements IDycmsDisplayable
/**
 * @desc
 * Base class for all widgets and modules. These form a
 * tree structure which is eventually translated into HTML
 * or XML (by walking the tree).
 */
{
	protected $mNodeParent;
	protected $mChildren = array();

	function __construct() {}

	function DisplayHeader() {}
	function DisplayFooter() {}
	function GetLabel() {return null;}

	function DisplayBody()
	{
		foreach($this->mChildren as $node)
		{
			$node->Display();
		};
	}

	function Display()
	{
		$this->DisplayHeader();
		$this->DisplayBody();
		$this->DisplayFooter();
	}

	function AddChild($node)
	{
		if(is_array($node)) foreach($node as $n){
			if(!($n instanceof cDycmsClientNode))
				$n = new cHtmlCode($n);

			array_push($this->mChildren, $n);
			$n->mNodeParent = $this;
		}else{
			if(!($node instanceof cDycmsClientNode))
				$node = new cHtmlCode($node);

			array_push($this->mChildren, $node);
			$node->mNodeParent = $this;
			return $node;
		};	
	}
	
	function GetParent(){
		return $this->mNodeParent;
	}
}

interface IDycmsClient extends IDycmsDisplayable
/**
 * @desc
 * Base class for the main rendering area, 'the page'.
 * Provides routines for getting and setting default content
 * and module containers, and including scripts and styles.
 */
{
	function &ContentNode();
	function SetContentNode(cDycmsClientNode &$r_node);

	function AddModule(cDycmsClientNode &$r_mod);
	function AddScript($sId);
	function AddStyle($sId);
	function AddMetaData($sId, $sValue);
}

?>
